#pragma once

#include "effectbase.h"
#include "commonshape.h"
#include <osg/NodeCallback>

namespace VrDataCore
{
	class SelectEffectCallback;

	class VRDATACORE_EXPORT SelectEffect:public EffectBase
	{
	public:
		SelectEffect();
	protected:
		~SelectEffect();
		//osg::ref_ptr<osg::Geode> createGeode(float radius,const osg::Vec3& color);
		//QVector<osg::Vec3> computePointVec(const osg::Vec3& centerpoint,float radius,int facenum
		//,const osg::Vec3& mu,const osg::Vec3& mv);
	public:
		virtual void buildPropertyMap();
		virtual void apply(CoreBase::ActorBase* actor);
		virtual void unApply(CoreBase::ActorBase* actor);
		void setMaterial(osg::Vec4 material);
		osg::Vec4 getMaterial();
		void update();
	private:
		osg::Vec4											_materialValue;
		osg::ref_ptr<CoreBase::CommonCylinder>				_drawable;
		osg::ref_ptr<SelectEffectCallback>					_uniformCenterCallback;
		osg::ref_ptr<SelectEffectCallback>					_uniformBottomCallback;
	};

	class SelectEffectCallback : public osg::Uniform::Callback
	{
	public:
		SelectEffectCallback():_times(0.0f)
		{}
		~SelectEffectCallback(){};
		virtual void operator()(osg::Uniform* uniform, osg::NodeVisitor* nv)
		{
			uniform->set(_times);
			_times++;
		}
		void reset(){_times = 0.0f;}
	protected:
		float							_times;
	};
}